package com.tansun.easycare.rule.effect.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.tansun.easycare.rule.common.RuleBaseController;
import com.tansun.easycare.rule.common.model.ResponseVO;
import com.tansun.easycare.rule.effect.model.manageInfoVO;
import com.tansun.easycare.rule.effect.service.RuleEffectService;

/**
 * 立即生效处理控制层
 */
@RestController
@RequestMapping(value = "/ruleProj/effect")
public class RuleEffectController extends RuleBaseController {
    @Autowired
    private RuleEffectService ruleEffectService;
    /**
     * modelType 1是函数变量 2其他组件 3部署信息
     * @param manageId
     * @param modelType
     * @return
     */
    @RequestMapping("doEffectRightNow")
    public ResponseVO doEffectNow(@RequestBody manageInfoVO infoVo){
    	ResponseVO res = new ResponseVO();
    	res.setStatus(200);
    	res.setDescription("立即生效成功！");
        try {
            ruleEffectService.doEffectNow(infoVo.getProjectCode(),infoVo.getModelType(),infoVo.getManageId());
        } catch (Exception e) {
            e.printStackTrace();
            res.setStatus(ResponseVO.ERROR);
        	res.setDescription("立即生效失败:"+e.getMessage());
        }
        return  res;
    }
}
